package cn.kgc.ssm.controller;

import cn.kgc.ssm.annotatios.LogOperation;
import cn.kgc.ssm.commons.ResponseResult;
import cn.kgc.ssm.entity.Message;
import cn.kgc.ssm.enums.OperationType;
import cn.kgc.ssm.service.MessageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 课工场
 * @date 2024/5/17
 * @description 留言管理
 */
@RestController
@RequestMapping("message")
public class MessageController {

    @Resource
    private MessageService messageService;

    // 留言的分页数据
    @RequestMapping("page")
    public ResponseResult messagePage(Integer page, Integer limit, String memberName) {

      return    messageService.messagePage(page,limit,memberName);
    }


    // 编辑留言状态
    @RequestMapping("edit")
    @LogOperation(model = "留言模块",operation = OperationType.UPDATE)
    public ResponseResult editMessage(Integer id) {
        return    messageService.editMessage(id);
    }


    // 编辑留言状态
    @RequestMapping("delete")
    @LogOperation(model = "留言模块",operation = OperationType.DELETE)
    public ResponseResult deleteMessage(Integer[] ids) {
        return    messageService.deleteMessage(ids);
    }

    // 添加留言
    @RequestMapping("add")
    public ResponseResult addMessage(Message message, HttpServletRequest request) {
        return    messageService.addMessage(message,request);
    }



}
